

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>CPU 剖析 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="内存剖析" href="../memory-profiling/" />
    <link rel="prev" title="日志记录和调试" href="../log-and-debug/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../">Ceph 存储集群</a></li>
          <li class="breadcrumb-item"><a href="../../operations/">集群运维</a></li>
      <li class="breadcrumb-item active">CPU 剖析</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../../_sources/rados/troubleshooting/cpu-profiling.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../">Ceph 存储集群</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../configuration/">配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../operations/">运维</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../man/">    手册页</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../">故障排除</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../community/">Ceph 社区</a></li>
<li class="toctree-l3"><a class="reference internal" href="../log-and-debug/">日志记录和调试</a></li>
<li class="toctree-l3"><a class="reference internal" href="../troubleshooting-mon/">监视器故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../troubleshooting-osd/">OSD 故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../troubleshooting-pg/">归置组排障</a></li>
<li class="toctree-l3"><a class="reference internal" href="../memory-profiling/">内存剖析</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">CPU 剖析</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#oprofile">初始化 oprofile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id1">启动 oprofile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">停止 oprofile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">查看 oprofile 运行结果</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">重置 oprofile</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="cpu">
<h1>CPU 剖析<a class="headerlink" href="#cpu" title="Permalink to this heading"></a></h1>
<p>如果你从源码编译时启用了 <a class="reference external" href="http://oprofile.sourceforge.net/about/">oprofile</a> ，那就可以剖析 Ceph 的 CPU 使用情况，详情见<a class="reference external" href="../../../dev/cpu-profiler">安装 Oprofile</a> 。</p>
<section id="oprofile">
<h2>初始化 oprofile<a class="headerlink" href="#oprofile" title="Permalink to this heading"></a></h2>
<p>你首次使用 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> 时要初始化，找到对应于当前运行内核的 <code class="docutils literal notranslate"><span class="pre">vmlinux</span></code> 映像：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ls</span> <span class="o">/</span><span class="n">boot</span>
<span class="n">sudo</span> <span class="n">opcontrol</span> <span class="o">--</span><span class="n">init</span>
<span class="n">sudo</span> <span class="n">opcontrol</span> <span class="o">--</span><span class="n">setup</span> <span class="o">--</span><span class="n">vmlinux</span><span class="o">=</span><span class="p">{</span><span class="n">path</span><span class="o">-</span><span class="n">to</span><span class="o">-</span><span class="n">image</span><span class="p">}</span> <span class="o">--</span><span class="n">separate</span><span class="o">=</span><span class="n">library</span> <span class="o">--</span><span class="n">callgraph</span><span class="o">=</span><span class="mi">6</span>
</pre></div>
</div>
</section>
<section id="id1">
<h2>启动 oprofile<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>执行下面的命令启动 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">opcontrol</span> <span class="o">--</span><span class="n">start</span>
</pre></div>
</div>
<p>启动 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> 后，你可以运行一些 Ceph 测试。</p>
</section>
<section id="id2">
<h2>停止 oprofile<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>执行下面的命令停止 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">opcontrol</span> <span class="o">--</span><span class="n">stop</span>
</pre></div>
</div>
</section>
<section id="id3">
<h2>查看 oprofile 运行结果<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>要查看 <code class="docutils literal notranslate"><span class="pre">cmon</span></code> 最近的结果，执行下面的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">opreport</span> <span class="o">-</span><span class="n">gal</span> <span class="o">./</span><span class="n">cmon</span> <span class="o">|</span> <span class="n">less</span>
</pre></div>
</div>
<p>要检索 <code class="docutils literal notranslate"><span class="pre">cmon</span></code> 最近的调用图结果，执行下面的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">opreport</span> <span class="o">-</span><span class="n">cal</span> <span class="o">./</span><span class="n">cmon</span> <span class="o">|</span> <span class="n">less</span>
</pre></div>
</div>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>回顾结果后，重新剖析前应该先重置，重置 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> 动作从会话目录里删除了数据。</p>
</div>
</section>
<section id="id4">
<h2>重置 oprofile<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>要重置 <code class="docutils literal notranslate"><span class="pre">oprofile</span></code> ，执行下面的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">opcontrol</span> <span class="o">--</span><span class="n">reset</span>
</pre></div>
</div>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>你应该分析后再重置，以免混合不同的剖析结果。</p>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../log-and-debug/" class="btn btn-neutral float-left" title="日志记录和调试" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../memory-profiling/" class="btn btn-neutral float-right" title="内存剖析" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>